package com.orange.score.service;

import android.os.AsyncTask;
import android.util.Log;
import com.orange.common.android.activity.PPActivity;
import com.orange.score.model.config.ConfigManager;
import com.orange.score.model.league.LeagueManager;
import com.orange.score.model.match.MatchManager;
import com.orange.score.network.ResultCodeType;
import com.orange.score.network.ScoreNetworkRequest;

public class WeeklyMatchService
{
  private static final String TAG = "MatchHistoryService";
  private LeagueManager leagueManager;
  private MatchManager matchManager = new MatchManager();

  public WeeklyMatchService()
  {
    this.leagueManager = new LeagueManager();
  }

  public MatchManager getMatchManager()
  {
    return this.matchManager;
  }

  public void loadWeeklyMatch(PPActivity paramPPActivity, WeeklyMatchServiceCallBack paramWeeklyMatchServiceCallBack, String paramString)
  {
    loadWeeklyMatchTask localloadWeeklyMatchTask = new loadWeeklyMatchTask(this, paramPPActivity, paramWeeklyMatchServiceCallBack, paramString);
    String[] arrayOfString = new String[1];
    arrayOfString[0] = "";
    localloadWeeklyMatchTask.execute(arrayOfString);
  }

  private class loadWeeklyMatchTask extends AsyncTask<String, Void, String[]>
  {
    PPActivity activity;
    WeeklyMatchServiceCallBack callBack;
    String date;

    public loadWeeklyMatchTask(, PPActivity paramPPActivity, WeeklyMatchServiceCallBack paramWeeklyMatchServiceCallBack, String paramString)
    {
      this.activity = paramPPActivity;
      this.date = paramString;
      this.callBack = paramWeeklyMatchServiceCallBack;
    }

    protected String[] doInBackground()
    {
      ConfigManager.getInstance();
      return ScoreNetworkRequest.getFinishMatch(ConfigManager.getLanguage(), this.date);
    }

    protected void onPostExecute()
    {
      this.activity.hideDialog();
      if (paramArrayOfString == null)
      {
        this.callBack.loadAllMatchFinish(ResultCodeType.ERROR_NO_DATA);
        Log.w("MatchHistoryService", "getFinalScoreMatch failed");
      }
      while (true)
      {
        return;
        Log.i("MatchHistoryService", "results" + paramArrayOfString.toString());
        int i = 1;
        if (paramArrayOfString.length == 1)
        {
          Log.w("MatchHistoryService", "no match/league data recv");
          i = 0;
        }
        String str1 = "";
        String str2 = "";
        if ((i != 0) && (paramArrayOfString.length >= 3))
        {
          str2 = paramArrayOfString[1];
          str1 = paramArrayOfString[2];
        }
        String[] arrayOfString1 = str2.split("\\!");
        WeeklyMatchService.access$0(this.this$0).updateDataFromStringList(arrayOfString1, 1);
        String[] arrayOfString2 = str1.split("\\!");
        WeeklyMatchService.access$1(this.this$0).updateDataFromStringList(arrayOfString2, WeeklyMatchService.access$0(this.this$0), null);
        Log.i("MatchHistoryService", WeeklyMatchService.access$1(this.this$0).getMatchList().toString());
        this.callBack.loadAllMatchFinish(ResultCodeType.SUCCESS);
      }
    }

    protected void onPreExecute()
    {
      this.activity.showProgressDialog("", "数据加载中...", this);
    }
  }
}